<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
	<head>
		<title><?php echo (L("_WEB_TITLE")); ?></title>
		<meta charset="UTF-8">
		<meta name="keywords" content="">
		<meta name="description" content="">
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<!-- intoHead  -->
		<link rel="stylesheet" type="text/css" href="<?php echo C('BOOTSTRAP');?>css/bootstrap.min.css?v=<?php echo C('VERSION');?>" />
		<link rel="stylesheet" type="text/css" href="<?php echo C('HOME_CSS');?>console.css?v=<?php echo C('VERSION');?>" />
		<script type="text/javascript" src="<?php echo C('HOME_JS');?>jquery-2.0.3.min.js?v=<?php echo C('VERSION');?>"></script>
		<script type="text/javascript" src="<?php echo C('HOME_JS');?>index.js?v=<?php echo C('VERSION');?>"></script>
		<script language="JavaScript" src="<?php echo C('LAYERUI');?>layui.js?v=<?php echo C('VERSION');?>"></script>
		<script language="JavaScript" src="<?php echo C('HOME_JS');?>function.js?v=<?php echo C('VERSION');?>"></script>
		<script>
		layui.use(['layer','form'], function(){
			var layer=layui.layer;
			var form =layui.form();
		});
		</script>
		<link rel="stylesheet" type="text/css" href="<?php echo C('HOME_CSS');?>iframe.css?v=<?php echo C('VERSION');?>" />
		<script>
			var city_url = "<?php echo C('HOME_JS');?>city.min.js";
		</script>
		<script type="text/javascript" src="<?php echo C('HOME_JS');?>jquery.cityselect.js"></script>
		<script type="text/javascript" src="<?php echo C('UPLOAD');?>jquery.form.js"></script>
		
	</head>
<style type="text/css">
	table{width:100%;}
	table td,table th{padding:6px 0px 6px 6px;background:#FFFFFF;}
	table th{text-align:center;line-height:30px;margin:5px;border-bottom:10px solid #f5f5f5;border-right:1px solid #DEDEDE;color:#3e3e3e;}
	table td{text-align:center;border-bottom:2px solid #DEDEDE;line-height:25px;}
	.spacess{color:#ccc;float:right;border-right:1px solid #DEDEDE;height:35px;}
	.opration{text-align: left !important;padding-left:30px;border-right:1px solid #DEDEDE;}
</style>
<body class="iframe-body">

 <div style="text-indent:10px;background:#EAEDF1;width:100%;position:fixed;top:0px;height:35px;line-height:35px;">
    <img style="position:relative;top:-2px;" src="<?php echo C('HOME_IMAGE');?>icon/sy_icon.png" width="15px;">
    <?php echo (L("_HOME_PAGE")); ?>
    &gt;
    <?php echo ($nav1); ?>
    &gt;
    <span style="color:#15b6be;"><?php echo ($nav2); ?></span>
    <span style="float:right;margin-right:10px;cursor:pointer;" onclick="location.reload()"><?php if((LANG_SET) == "zh-cn"): ?>刷新<?php else: ?>refresh<?php endif; ?></span>
</div>
<div class="body">
<table class="table table-bordered">
  <tr class="active">
  	<th><?php echo (L("USER_NUM")); ?></th><th><?php echo (L("_FIRST_MENU")); ?></th><th><?php echo (L("_SECOND_MENU")); ?></th><th><?php echo (L("USER_ACTION")); ?></th>
  </tr>
  <?php if(is_array($menus)): $i = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
  	<td><?php echo ($vo["id"]); ?></td><td><?php echo ($vo["name"]); ?></td><td></td><td data_id="<?php echo ($vo["id"]); ?>" class="add_child_menu pointer"><?php echo (L("MENU_ADD_CHILD")); ?></td>
  </tr>
  <?php if(is_array($vo["child_menu"]["child_menu"])): $i = 0; $__LIST__ = $vo["child_menu"]["child_menu"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo_child): $mod = ($i % 2 );++$i;?><tr>
  	<td><?php echo ($vo_child["id"]); ?></td><td align="center">|--</td><td><?php echo ($vo_child["name"]); ?></td><td data_id="<?php echo ($vo_child["id"]); ?>" class="del_child_menu pointer"><?php echo (L("_DELETE")); ?></td>
  </tr><?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?>
</table>
</div>
<script>
	  $('.table').on('click','.add_child_menu',function(){
		  var pid = $(this).attr('data_id');
		  var html = '<div><?php echo (L("MENU_NAME")); ?><input type="text" id="child_menu_name" class="form-control"></div>'+
			'<div><?php echo (L("USER_ACTION")); ?><input type="text" id="child_menu_action" class="form-control"></div>';
		  parent.layer.open({
			  title:'<?php echo (L("_ADD")); echo (L("MENU")); ?>',
			  btn:['<?php echo (L("_SURE")); ?>','<?php echo (L("_CANCEL")); ?>'],
			  content: html,
			  yes: function(index, layero){
			    var name = parent.$('#child_menu_name').val();
			    var action=parent.$('#child_menu_action').val();
			    if(!name){
			    	parent.layer.msg('<?php echo (L("MENU_INPUT_MENUNAME")); ?>');
			    	return false;
			    }
			    if(!action){
			    	parent.layer.msg('<?php echo (L("MENU_INPUT_MENUACTION")); ?>');
			    	return false;
			    }
			    var data = {name:name,action:action,pid:pid};
			    $.post("<?php echo U('Ajax/add_menu');?>",data,function(r){
			    	if(r.code == 1){
			    		parent.layer.msg('<?php echo (L("_SUCCESS")); ?>',{time:1000},function(){
			    			location.reload();
			    		})
			    	}else{
			    		parent.layer.msg('<?php echo (L("_FAIL")); ?>')
			    	}
			    })
			  }
		  })
	  })
	  $('.table').on('click','.del_child_menu',function(){
		  var id = $(this).attr('data_id');
		  parent.layer.confirm('<?php echo (L("MENU_DELETE")); ?>？', {
			  btn: ['<?php echo (L("_SURE")); ?>','<?php echo (L("_CANCEL")); ?>'] //按钮
			}, function(){
				var data = {id:id};
			    $.post("<?php echo U('Ajax/del_menu');?>",data,function(r){
			    	if(r.code == 1){
			    		parent.layer.msg('<?php echo (L("_SUCCESS")); ?>',{time:1000},function(){
			    			location.reload();
			    		})
			    	}else{
			    		parent.layer.msg('<?php echo (L("_FAIL")); ?>')
			    	}
			    })
			});
	  })
</script>